<template>
	<view class="logistics">
		<view class="content">
			<view v-for="(item, index) in dataList" :key="index" class="content-item">
				<view class="row">
					<view class="row-label">设备型号</view>
					<view class="row-value">{{ item.marking || "" }}</view>
				</view>
				<view class="row">
					<view class="row-label">设备序列号</view>
					<view class="row-value">{{ item.serial || "" }}</view>
				</view>

				<view class="row">
					<view class="row-label">图片</view>
					<view class="row-value">
						<image v-for="(img, k) in item.express_images" :key="k" :src="img"
							@click="preview(k, item.express_images)" />
					</view>
				</view>
			</view>
		</view>
		<empty v-if="dataList.length == 0" />
	</view>
</template>

<script>
	import empty from "@/components/empty.vue";
	import xflSelect from "@/components/xfl-select/xfl-select.vue";
	export default {
		components: {
			empty,
			xflSelect,
		},
		data() {
			return {
				dataList: [],
				last_page: 1,
				queryParams: {
					express_type: "",
					name: "",
					mobile: "",
					express_number: "",
					newcustomer_id: "",
					work_order_number: "",
					page: 1,
				},
				equipment_id:null,
			};
		},
		onLoad(e) {
			this.equipment_id = e.id
		},
		onShow() {
			this.handleQuery();
		},
		methods: {
			getList() {
				this.$https.post("/hospital/getEquipAttachmentList", {
					equipment_id: this.equipment_id 
				}).then((res) => {
					if (res.code == 1) {
						this.dataList = res.data.map(item => {
							return {
								...item,
								express_images: item.images?item.images.split(','):[]
							}
						})
					}
				});
			},
			// 预览图片
			preview(current, urls) {
				uni.previewImage({
					current,
					urls,
				});
			},

			// 筛选
			handleFilter() {
				this.$refs.filterRef.open();
			},

			// 条件搜索
			handleQuery() {
				this.queryParams.page = 1;
				this.getList();
			},
		},
		onReachBottom() {
			if (this.queryParams.page != this.last_page) {
				this.queryParams.page = this.queryParams.page + 1;
				this.getList();
			}
		},
	};
</script>

<style lang="scss" scoped>
	.logistics {
		background-color: #f7f8fb;
		padding: 10rpx 32rpx 18rpx;
		min-height: 100vh;

		.query {
			display: flex;
			align-items: center;
			height: 80rpx;
			justify-content: space-between;
			color: #fff;
			position: sticky;
			top: 0;
			z-index: 9;
			background-color: #f7f8fb;
			padding: 10rpx;
			font-size: 26rpx;

			.btn_add {
				padding: 12rpx 20rpx;
				background-color: #409eff;
				border-radius: 50rpx;
			}

			.btn_filter {
				padding: 12rpx 30rpx;
				background-color: #7ac85e;
				border-radius: 50rpx;
			}
		}

		.content {
			&-item {
				box-shadow: 10rpx 10rpx 20rpx rgba(0, 0, 0, 0.05);
				background-color: #fff;
				border-radius: 20rpx;
				padding: 20rpx;
				margin: 20rpx 0;
				position: relative;
				overflow: hidden;

				.tag {
					position: absolute;
					right: 0;
					top: 0;
					padding: 10rpx 30rpx;
					font-size: 24rpx;
					color: #fff;
					background-color: #82dcec;
					border-radius: 0 20rpx 0 20rpx;
				}

				.row {
					display: flex;
					align-items: center;
					font-size: 26rpx;
					line-height: 44rpx;

					&-label {
						color: #969699;
						width: 160rpx;
					}

					&-value {
						color: #303030;
						flex: 1;
						word-break: break-all;

						image {
							width: 120rpx;
							height: 120rpx;
							margin-right: 20rpx;
							margin-bottom: 20rpx;
						}
					}
				}

				.send {
					background-color: #82dcec;
				}

				.receive {
					background-color: #f8c168;
				}
			}
		}
	}

	.filter-box {
		background-color: #fff;
		width: 600rpx;
		height: 100%;
		position: relative;
		z-index: 99;

		.filter-row {
			color: #303030;
			font-size: 28rpx;
			padding: 20rpx;
		}

		.border {
			border: 1rpx solid #b7b7b7;
			border-radius: 10rpx;
			margin: 0 20rpx;
			padding: 20rpx;
		}

		.bottom_btn {
			position: absolute;
			bottom: 0;
			width: 100%;
			display: flex;
			align-items: center;

			view {
				flex: 1;
				color: #fff;
				display: flex;
				height: 80rpx;
				align-items: center;
				justify-content: center;
			}

			.left_btn {
				background-color: #409eff;
			}

			.right_btn {
				background-color: #7ac85e;
			}
		}
	}
</style>